import Cookies from 'js-cookie'

const TokenKey = 'ppk-token'
// const TokenKey = 'vue_admin_template_token'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

// ! localStorage 存储  json未处理
export function localgettoken() {
  return localStorage.getItem(TokenKey)
}
export function localsettoken(token) {
  return localStorage.setItem(TokenKey, token)
}
export function localremovetoken() {
  return localStorage.removeItem(TokenKey)
}
export function getUserName() {
  // console.log(JSON.parse(localStorage.getItem(TokenKey)), 'sdafasdf', JSON.parse(localStorage.getItem(TokenKey)))
  if (!localStorage.getItem(TokenKey)) return '-'
  if (!JSON.parse(localStorage.getItem(TokenKey))) return '-'
  return JSON.parse(localStorage.getItem(TokenKey)).userNo
}
